function insert_sort(arr) {
    for (let i = 0; i < arr.length; i++) {
        let tmp = arr[i],
            l = 0,
            r = i - 1;
        while (l <= r) {
            let mid = (l + r) >> 1;
            if (arr[mid] >= tmp) {
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        for (let j = i - 1; j >= l; j--) arr[j + 1] = arr[j];
        arr[l] = tmp;
    }
}

let arr = [5, 8, 9, 6, 7, 3, 2, 0, 1, 4];
insert_sort(arr);
console.log(arr);
